function val = aboveTriangle( A,B,C,P )
%ABOVETRIANGLE (A,B,C,P) 3D points for triangle A,B,C and the point P
%   return true if the point P is above the triangle ABC

%find the plane equation that passes A,B,C, [x' 1]*[a;d]=0;
pointMat=[A, B, C];
pointMat=[pointMat' ones(3,1)];
coeff=null(pointMat);

%make the normal vector to point positive z direction
if coeff(3)<0
    coeff=-coeff;
end

%return true if the point is above the plane
val=(coeff'*[P; 1] >0);

end
